﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<script src="/Assets/Scripts/jsGui/jquery.effects.core.js" type="text/javascript"></script>
<script src="/Assets/Scripts/jsGui/jquery.ui.resizable.js" type="text/javascript"></script>
<script src="/Assets/Scripts/jsGui/jquery.ui.draggable.js" type="text/javascript"></script>
<script src="/Assets/Scripts/jsGui/jquery.ui.mouse.js" type="text/javascript"></script>
<script src="/Assets/Scripts/jsGui/jquery.ui.position.js" type="text/javascript"></script>
<script src="/Assets/Scripts/jsGui/jquery.effects.blind.js" type="text/javascript"></script>
<script src="/Assets/Scripts/jsGui/jquery.effects.explode.js" type="text/javascript"></script>
<script src="/Assets/Scripts/jquery-ui-1.8.11.custom.js" type="text/javascript"></script>


 
<style type="text/css">
    #orderTable
    {
        border:1px solid #0073EA;
        }
    #orderTable th
    {
        height:50px;
        text-align:center;
        vertical-align:middle;
        }
        #orderTable td
    {
        text-align:center;
        vertical-align:middle;
        padding:10px;
        }
</style>
<table id="orderTable"  border="1px solid #0073EA" cellpadding="1" cellspacing="1"   width="100%">
		<tr class="ui-state-hover">
			<th  valign="top" style="text-align: center;">Ngày Mua</th>
			<th valign="top" style="text-align: center;">Ghế mua</th>
            <th valign="top" style="text-align: center;">Nhà Xe</th>
            <th valign="top" style="text-align: center;">Xe đi</th>
            <th valign="top" style="text-align: center;">Trạng thái</th>
            <th valign="top" style="text-align: center;">Chi tiết</th>
		</tr>
       
        <%
            List<ASPNETMVCApplication.Areas.Cust.ViewModels.OrderViewModels> listOrderView = (List<ASPNETMVCApplication.Areas.Cust.ViewModels.OrderViewModels>)ViewData["listOrderNew"];
            int i = 0;
            %>
                
            <%
            foreach (var item in listOrderView)
           {
                if(i%2==0)
                {
                %>

                <tr >
		            <td><%: item._order.OrderDate %></td>
		            <td >Ghế :<% foreach (var proc in item._listOrderDetail)
                                  {
                                    %>
                                    <b><%: proc.ProductName %>,</b>
                                    <%   
                                  }
                    %></td>
		            <td><%: item._supplier.CompanyName %><b>Liên hệ :<%:item._supplier.Mobilephone %></b></td>
		            <td><%: item._traffic.TrafficName%></td>
		            <td><% if (item._order.Status == 0)
                     {
                         %>
                         <a class="details">Chưa thanh toán</a>
                        <%
                            }
                     else
                     {
                         %>
                         <a class="details">Đã thanh toán</a>
                         <% 
                     }
                %>
                     </td>
                      <td>
                      

                        <button id="chitiet<%: i %>" onclick="ShowDialog(<%:i %>)" >Chi tiết</button>
                        <div id="form-detail<%: i %>">
                            <% using (Ajax.BeginForm("OrderApprove","Order",new AjaxOptions{ OnSuccess="success" }))
                               {
                                   %>
                                   <table width="100%">
                                  <tr>
                                    <th>Ghế mua</th>
                                    <th>Chọn</th>
                                  </tr>
                                    <% foreach (var proc in item._listOrderDetail)
                                  {
                                    %>
                                        <tr>
                                            <td align=center>Ghế :<b style="color:Maroon"> <%: proc.ProductName %></b></td>
                                            <td align=center><input type="checkbox" id="ghe<%: proc.ProductName %>" name="ghe" /></td>    
                                        </tr>
                                    <%   
                                  }
                                    %>
                                    <tr>
                                            <td align=center><input type="submit" value="Chấp nhận bán" /></td>
                                            <td align=center><button id="Button2" onclick="return CloseAllDialog();" >Cancel</button></td>    
                                        </tr>
                                </table>
                                <div id="success"></div>

                              <% } %>
                        </div>
                     </td>
	            </tr>
                <% 
                    }else
                {
                    %>
                        <tr style="background-color:#ffffcc;">
		            <td><%: item._order.OrderDate %></td>
		            <td >Ghế :<% foreach (var proc in item._listOrderDetail)
                                  {
                                    %>
                                    <b><%: proc.ProductName %>,</b>
                                    <%   
                                  }
                    %></td>
		            <td><%: item._supplier.CompanyName %><b>Liên hệ :<%:item._supplier.Mobilephone %></b></td>
		            <td><%: item._traffic.TrafficName%></td>
		            <td><% if (item._order.Status == 0)
                     {
                         %>
                         <a class="details">Chưa thanh toán</a>
                        <%
                            }
                     else
                     {
                         %>
                         <a class="details">Đã thanh toán</a>
                         <% 
                     }
                    
                %>
                     </td>
                     <td>
                      

                       

                        <button id="dt" onclick="ShowDialog(<%:i %>)" >Chi tiết</button>
                        <div id="form-detail<%: i %>">
                            <% using (Ajax.BeginForm("OrderApprove","Order",new AjaxOptions{ OnSuccess="success" }))
                               {
                                   %>
                                   <table width="100%">
                                  <tr>
                                    <th>Ghế mua</th>
                                    <th>Chọn</th>
                                  </tr>
                                    <% foreach (var proc in item._listOrderDetail)
                                  {
                                    %>
                                        <tr>
                                           <td align=center>Ghế :<b style="color:Maroon"> <%: proc.ProductName %></b></td>
                                            <td align=center><input type="checkbox" id="ghe<%:proc.ProductName %>" name="ghe" /></td> 
                                        </tr>
                                    <%   
                                  }
                                    %>
                                    <tr>
                                            <td align=center><input type="submit" value="Chấp nhận bán" /></td>
                                            <td align=center><button id="Button2" onclick="return CloseAllDialog();" >Cancel</button></td>    
                                        </tr>
                                </table>
                                <div id="success"></div>

                              <% } %>
                        </div>
                     </td>
	            </tr>
                    <%
                }
                        i++;
               
           } 
        %>


                     <script>
                         // increase the default animation speed to exaggerate the effect
                         function CreateAllDialog() { 
                             for(var j=0;j<<%: listOrderView.Count %>;j++)
                             {
                                $("#form-detail" + j).dialog({
                                 autoOpen: false,
                                 modal: true,
                                 show: "blind"
                             });
                             }
                             $.fx.speeds._default = 1000;
                         };
                         function CloseAllDialog() { 
                             for(var j=0;j<<%: listOrderView.Count %>;j++)
                             {
                                $("#form-detail" + j).dialog("close");
                             }
                             $.fx.speeds._default = 1000;
                             return false;
                         };

                         CreateAllDialog();
                         function ShowDialog(str) {
                                CloseAllDialog();
                                 $("#form-detail" + str).dialog("open");
                         };
	                </script>
	</table>